/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Validaciones;

/**
 *
 * @author pablo
 */
public class Validacion  {
    private boolean validacion(String cadena, String PATTERN) {
        return cadena.matches(PATTERN);
    }
    public void vacio(String cadena,String inf) throws EstaVacioException{
        if(cadena.trim().isEmpty())
            throw new EstaVacioException(inf+" Esta Vacio");
    }
    public void sonNumeros(String cadena,String inf) throws NoesNumeroExeption, EstaVacioException  {
        vacio(cadena,inf);
        if (!validacion(cadena, "[\\d]*")) {
            throw new NoesNumeroExeption(inf+" No Es numerico");
        }
    }

    public void sonLetras(String cadena,String inf) throws NoesCaracteresException, EstaVacioException {
        vacio(cadena,inf);
        if (!validacion(cadena, "[a-zA-Z]*")) {
            throw new NoesCaracteresException(inf+" No son Letras");
        }
    }

    public void sonSimbolos(String cadena, String inf) throws NoesCaracteresException, EstaVacioException {
        vacio(cadena, inf);
        if (validacion(cadena, "[@#$%^^&*]*")) {
            throw new NoesCaracteresException(inf + " No se permite el ingreso de estos simbolos");
        }
    }
    
  
    public void diezNumeros(String cadena,String inf) throws NoesDiezNumeros, NoesNumeroExeption, EstaVacioException {
        sonNumeros(cadena,inf);
        if (cadena.length() != 10) {
            throw new NoesDiezNumeros(inf+" No estan los 10 Digitos");
        }
    }

    public void esCedula(String cadena,String inf) throws NoesDiezNumeros, NoesNumeroExeption, EstaVacioException {
        
        diezNumeros(cadena,inf);
        // if(true)
        //    throw new CedulaException("No es una cedula");
    }

}
